// $(window).load = function () {
$(function () {
    //大图轮播
    //自动轮播
    var tmpnum = 0;
    var tmpArr = ["#ffaaad","#01479d","#c4a7bb","#fadadf","#ffffff","#ffffff","#24575a"]
    function autoPlay() {
        // console.log(tmpnum);
        tmpnum++;
        if (tmpnum > 6) {
            tmpnum = 0;
        }
        //淡入淡出
        $(".header5Main>ul>li").animate({ opacity: 0 }, 500)
        $(".header5Main>ul>li").eq(tmpnum).animate({ opacity: 1 }, 500);
        
        $(".header5Main>ul>ul>li").css("background","#fff");
        $(".header5Main>ul>ul>li").eq(tmpnum).css("background","#000");
        $(".header5").css("background",tmpArr[tmpnum]);
    }
    var timer = setInterval(autoPlay, 3000);
    //鼠标移入移出事件
    $(".header5Main>ul").mouseenter(function(){
        clearInterval(timer);
        $(".header5Main>ul>span").css("display","block");
    }).mouseleave(function(){
        timer = setInterval(autoPlay, 3000);
        $(".header5Main>ul>span").css("display","none");
    })
    //给prev和next添加点击事件
    $(".header5Main>ul>.prev").click(function(){
        tmpnum -=2;
        if(tmpnum<-1){
            tmpnum=5;
        }
        autoPlay();
    })
    $(".header5Main>ul>.next").click(function(){
        autoPlay();
    })
    //给Dotted里的li添加鼠标移入事件
    $(".header5Main>ul>.Dotted>li").mouseenter(function(){
        var $index = $(this).index();
        // console.log($index);
        tmpnum=$index-1;
        autoPlay();
    })
})

